package ModeLayer;
import java.util.ArrayList;

/**
 * Write a description of class ContainerForest here.
 * 
 * @author (Kis Boisen Hansen) 
 * @version (2014.01.04)
 */
public class ContainerOwner
{
   
    private static ContainerOwner instance;
    private ArrayList<Owner> ownerList;
    /**
     * Constructor for objects of class ContainerForest
     */
    private ContainerOwner()
    {
        // initialise instance variables
       ownerList = new ArrayList<Owner>();
    }

    //Singelton
    public static ContainerOwner getInstance() 
    {
        if(instance == null)
        {
            instance = new ContainerOwner();
        }
        return instance;
       
    }
    public void addOwner(Owner newOwner)
    {
        ownerList.add(newOwner);
    }
    public Owner findOwner (String name)
    {
        int index =0;
        boolean found = false;
        while(index < ownerList.size() && !found)
        {
            Owner ownerObj = ownerList.get(index);
            if(ownerObj.getOwnerName().equals(name))
            {
                found = true;
            }
            else{
                index ++;
            }
                    
        }
        if(found)
        {
            return ownerList.get(index);
        }
        else{
            return null;
        }
    
    }
}